home *** CD-ROM | disk | FTP | other *** search
/ 10,000 Great Games / 10,000 Great Games.iso / Product / 66 / data1.cab / Source_Files / Src / Profile.cpp < prev    next >
C/C++ Source or Header  |  2000-01-16  |  8KB  |  167 lines

  1. #include "stdafx.h"
  2.  
  3. char temp_path[256], autosave_level[256], clipboard_level[256];
  4.  
  5. void read_profile()
  6. {
  7.     // Get temporary dir
  8.     
  9.     int l = GetTempPath(256, temp_path);
  10.  
  11.     if (l > 0 && temp_path[l-1] != '\\')
  12.         strcat(temp_path, "\\");
  13.  
  14.     // Create autosave filename
  15.  
  16.     strcpy(autosave_level, temp_path);
  17.     strcat(autosave_level, AUTOSAVE_LEVEL);
  18.  
  19.     // Create clipboard filename
  20.  
  21.     strcpy(clipboard_level, temp_path);
  22.     strcat(clipboard_level, CLIPBOARD_LEVEL);
  23.     
  24.     // Get state of edit menu
  25.  
  26.     snap_to_grid = theApp.GetProfileInt(SEC_EDIT, "Snap to Grid", FALSE);
  27.  
  28.     // Get state of view menu
  29.  
  30.     view_backgroundarea = theApp.GetProfileInt(SEC_VIEW, "Background Area", TRUE);
  31.     view_gamearea = theApp.GetProfileInt(SEC_VIEW, "Game Area", TRUE);
  32.     view_grid = theApp.GetProfileInt(SEC_VIEW, "Grid", FALSE);
  33.     debug = theApp.GetProfileInt(SEC_VIEW, "Debug Info", FALSE);
  34.  
  35.     // Get state of settings menu
  36.  
  37.     no_blit_hardware = theApp.GetProfileInt(SEC_SETTINGS, "No Blit Hardware", FALSE);
  38.     no_parallax = theApp.GetProfileInt(SEC_SETTINGS, "No Parallax", FALSE);
  39.     low_detail_level = theApp.GetProfileInt(SEC_SETTINGS, "Low Detail Level", FALSE);
  40.     names_visible = theApp.GetProfileInt(SEC_SETTINGS, "Names Visible", FALSE);
  41.     no_armor = theApp.GetProfileInt(SEC_SETTINGS, "No Armor", FALSE);
  42.     gamma = (double)theApp.GetProfileInt(SEC_SETTINGS, "Gamma", 100) / 100;
  43.  
  44.     // Get controls
  45.  
  46.     strcpy(pl_name[0], theApp.GetProfileString(SEC_PLAYERS, "Pl1 Name", "Jorrit"));
  47.     strcpy(pl_name[1], theApp.GetProfileString(SEC_PLAYERS, "Pl2 Name", "Dennis"));
  48.     strcpy(pl_name[2], theApp.GetProfileString(SEC_PLAYERS, "Pl3 Name", "Peter"));
  49.     strcpy(pl_name[3], theApp.GetProfileString(SEC_PLAYERS, "Pl4 Name", "Steven"));
  50.     strcpy(pl_name[4], theApp.GetProfileString(SEC_PLAYERS, "Pl5 Name", "Heidi"));
  51.     strcpy(pl_name[5], theApp.GetProfileString(SEC_PLAYERS, "Pl6 Name", "Maarten"));
  52.     strcpy(pl_name[6], theApp.GetProfileString(SEC_PLAYERS, "Pl7 Name", "Reinier"));
  53.     strcpy(pl_name[7], theApp.GetProfileString(SEC_PLAYERS, "Pl8 Name", "Elmer"));
  54.     
  55.     pl_selected[0] = theApp.GetProfileInt(SEC_PLAYERS, "Pl1 Selected", TRUE);
  56.     pl_selected[1] = theApp.GetProfileInt(SEC_PLAYERS, "Pl2 Selected", TRUE);
  57.     pl_selected[2] = theApp.GetProfileInt(SEC_PLAYERS, "Pl3 Selected", FALSE);
  58.     pl_selected[3] = theApp.GetProfileInt(SEC_PLAYERS, "Pl4 Selected", FALSE);
  59.     pl_selected[4] = theApp.GetProfileInt(SEC_PLAYERS, "Pl5 Selected", FALSE);
  60.     pl_selected[5] = theApp.GetProfileInt(SEC_PLAYERS, "Pl6 Selected", FALSE);
  61.     pl_selected[6] = theApp.GetProfileInt(SEC_PLAYERS, "Pl7 Selected", FALSE);
  62.     pl_selected[7] = theApp.GetProfileInt(SEC_PLAYERS, "Pl8 Selected", FALSE);
  63.  
  64.     key_left[0] = theApp.GetProfileInt(SEC_CONTROLS, "Key 1 Left", DIK_LEFT);
  65.     key_right[0] = theApp.GetProfileInt(SEC_CONTROLS, "Key 1 Right", DIK_RIGHT);
  66.     key_up[0] = theApp.GetProfileInt(SEC_CONTROLS, "Key 1 Up", DIK_UP);
  67.     key_down[0] = theApp.GetProfileInt(SEC_CONTROLS, "Key 1 Down", DIK_DOWN);
  68.     key_fire[0] = theApp.GetProfileInt(SEC_CONTROLS, "Key 1 Fire", DIK_RCONTROL);
  69.  
  70.     key_left[1] = theApp.GetProfileInt(SEC_CONTROLS, "Key 2 Left", DIK_Z);    
  71.     key_right[1] = theApp.GetProfileInt(SEC_CONTROLS, "Key 2 Right", DIK_C);
  72.     key_up[1] = theApp.GetProfileInt(SEC_CONTROLS, "Key 2 Up", DIK_S);
  73.     key_down[1] = theApp.GetProfileInt(SEC_CONTROLS, "Key 2 Down", DIK_X);
  74.     key_fire[1] = theApp.GetProfileInt(SEC_CONTROLS, "Key 2 Fire", DIK_LCONTROL);
  75.  
  76.     key_left[2] = theApp.GetProfileInt(SEC_CONTROLS, "Key 3 Left", DIK_J);
  77.     key_right[2] = theApp.GetProfileInt(SEC_CONTROLS, "Key 3 Right", DIK_L);    
  78.     key_up[2] = theApp.GetProfileInt(SEC_CONTROLS, "Key 3 Up", DIK_I);    
  79.     key_down[2] = theApp.GetProfileInt(SEC_CONTROLS, "Key 3 Down", DIK_K);
  80.     key_fire[2] = theApp.GetProfileInt(SEC_CONTROLS, "Key 3 Fire", DIK_SPACE);
  81.  
  82.     reverse_mouse = theApp.GetProfileInt(SEC_CONTROLS, "Mouse Reverse", FALSE);
  83.  
  84.     for (int i = 0; i < kMaxJoys; i++)
  85.     {
  86.         strcpy(joy_str[i], theApp.GetProfileString(SEC_CONTROLS, construct("Joy %d", i+1), ""));
  87.         joy_fire[i] = theApp.GetProfileInt(SEC_CONTROLS, construct("Joy %d Fire", i+1), DIJOFS_BUTTON0);
  88.         joy_jetpack[i] = theApp.GetProfileInt(SEC_CONTROLS, construct("Joy %d Jetpack", i+1), DIJOFS_BUTTON1);
  89.         joy_mine[i] = theApp.GetProfileInt(SEC_CONTROLS, construct("Joy %d Mine", i+1), DIJOFS_BUTTON2);
  90.     }
  91. }
  92.  
  93. void write_profile()
  94. {
  95.     // Delete temp files
  96.  
  97.     DeleteFile(autosave_level);
  98.     DeleteFile(clipboard_level);
  99.  
  100.     // Write state of edit menu
  101.  
  102.     theApp.WriteProfileInt(SEC_EDIT, "Snap to Grid", snap_to_grid);
  103.  
  104.     // Write state of view menu
  105.  
  106.     theApp.WriteProfileInt(SEC_VIEW, "Background Area", view_backgroundarea);
  107.     theApp.WriteProfileInt(SEC_VIEW, "Game Area", view_gamearea);
  108.     theApp.WriteProfileInt(SEC_VIEW, "Grid", view_grid);
  109.     theApp.WriteProfileInt(SEC_VIEW, "Debug Info", debug);
  110.     
  111.     // Write state of settings menu    
  112.     
  113.     theApp.WriteProfileInt(SEC_SETTINGS, "No Blit Hardware", no_blit_hardware);
  114.     theApp.WriteProfileInt(SEC_SETTINGS, "No Parallax", no_parallax);
  115.     theApp.WriteProfileInt(SEC_SETTINGS, "Low Detail Level", low_detail_level);
  116.     theApp.WriteProfileInt(SEC_SETTINGS, "Names Visible", names_visible);
  117.     theApp.WriteProfileInt(SEC_SETTINGS, "No Armor", no_armor);
  118.     theApp.WriteProfileInt(SEC_SETTINGS, "Gamma", (int)(gamma * 100));
  119.  
  120.     // Write controls
  121.  
  122.     theApp.WriteProfileString(SEC_PLAYERS, "Pl1 Name", pl_name[0]);
  123.     theApp.WriteProfileString(SEC_PLAYERS, "Pl2 Name", pl_name[1]);
  124.     theApp.WriteProfileString(SEC_PLAYERS, "Pl3 Name", pl_name[2]);
  125.     theApp.WriteProfileString(SEC_PLAYERS, "Pl4 Name", pl_name[3]);
  126.     theApp.WriteProfileString(SEC_PLAYERS, "Pl5 Name", pl_name[4]);
  127.     theApp.WriteProfileString(SEC_PLAYERS, "Pl6 Name", pl_name[5]);
  128.     theApp.WriteProfileString(SEC_PLAYERS, "Pl7 Name", pl_name[6]);
  129.     theApp.WriteProfileString(SEC_PLAYERS, "Pl8 Name", pl_name[7]);
  130.  
  131.     theApp.WriteProfileInt(SEC_PLAYERS, "Pl1 Selected", pl_selected[0]);
  132.     theApp.WriteProfileInt(SEC_PLAYERS, "Pl2 Selected", pl_selected[1]);
  133.     theApp.WriteProfileInt(SEC_PLAYERS, "Pl3 Selected", pl_selected[2]);
  134.     theApp.WriteProfileInt(SEC_PLAYERS, "Pl4 Selected", pl_selected[3]);
  135.     theApp.WriteProfileInt(SEC_PLAYERS, "Pl5 Selected", pl_selected[4]);
  136.     theApp.WriteProfileInt(SEC_PLAYERS, "Pl6 Selected", pl_selected[5]);    
  137.     theApp.WriteProfileInt(SEC_PLAYERS, "Pl7 Selected", pl_selected[6]);    
  138.     theApp.WriteProfileInt(SEC_PLAYERS, "Pl8 Selected", pl_selected[7]);    
  139.  
  140.     theApp.WriteProfileInt(SEC_CONTROLS, "Key 1 Left", key_left[0]);
  141.     theApp.WriteProfileInt(SEC_CONTROLS, "Key 1 Right", key_right[0]);
  142.     theApp.WriteProfileInt(SEC_CONTROLS, "Key 1 Up", key_up[0]);
  143.     theApp.WriteProfileInt(SEC_CONTROLS, "Key 1 Down", key_down[0]);
  144.     theApp.WriteProfileInt(SEC_CONTROLS, "Key 1 Fire", key_fire[0]);
  145.  
  146.     theApp.WriteProfileInt(SEC_CONTROLS, "Key 2 Left", key_left[1]);
  147.     theApp.WriteProfileInt(SEC_CONTROLS, "Key 2 Right", key_right[1]);
  148.     theApp.WriteProfileInt(SEC_CONTROLS, "Key 2 Up", key_up[1]);
  149.     theApp.WriteProfileInt(SEC_CONTROLS, "Key 2 Down", key_down[1]);
  150.     theApp.WriteProfileInt(SEC_CONTROLS, "Key 2 Fire", key_fire[1]);
  151.  
  152.     theApp.WriteProfileInt(SEC_CONTROLS, "Key 3 Left", key_left[2]);
  153.     theApp.WriteProfileInt(SEC_CONTROLS, "Key 3 Right", key_right[2]);
  154.     theApp.WriteProfileInt(SEC_CONTROLS, "Key 3 Up", key_up[2]);
  155.     theApp.WriteProfileInt(SEC_CONTROLS, "Key 3 Down", key_down[2]);
  156.     theApp.WriteProfileInt(SEC_CONTROLS, "Key 3 Fire", key_fire[2]);
  157.  
  158.     theApp.WriteProfileInt(SEC_CONTROLS, "Mouse Reverse", reverse_mouse);
  159.  
  160.     for (int i = 0; i < kMaxJoys; i++)
  161.     {
  162.         theApp.WriteProfileString(SEC_CONTROLS, construct("Joy %d", i+1), joy_str[i]);
  163.         theApp.WriteProfileInt(SEC_CONTROLS, construct("Joy %d Fire", i+1), joy_fire[i]);
  164.         theApp.WriteProfileInt(SEC_CONTROLS, construct("Joy %d Jetpack", i+1), joy_jetpack[i]);
  165.         theApp.WriteProfileInt(SEC_CONTROLS, construct("Joy %d Mine", i+1), joy_mine[i]);
  166.     }
  167. }